$(document).ready(function() {
	$('#enterprise').dataTable({
		"bProcessing" : true, //DataTables载入数据时，是否显示‘进度’提示
		"bServerSide" : true, //是否启动服务器端数据导入
		"bStateSave" : false, //是否打开客户端状态记录功能,此功能在ajax刷新纪录的时候不会将个性化设定回复为初始化状态
		"bJQueryUI" : true, //是否使用 jQury的UI theme
		"aLengthMenu" : [5, 10, 15], //更改显示记录数选项
		"iDisplayLength" : 10, //默认显示的记录数
		"bAutoWidth" : true, //是否自适应宽度 update
		"bScrollCollapse" : false, //是否开启DataTables的高度自适应，当数据条数不够分页数据条数的时候，插件高度是否随数据条数而改变
		"bPaginate" : true, //是否显示（应用）分页器
		"bInfo" : true, //是否显示页脚信息，DataTables插件左下角显示记录数
		"sPaginationType" : "full_numbers", //详细分页组，可以支持直接跳转到某页
		"bSort" : true, //是否启动各个字段的排序功能
		"aaSorting" : [[0, "ASC"]], //默认的排序方式，第3列，升序排列
		"bFilter" : false, //是否启动过滤、搜索功能
		"sPaginationType": "full_numbers",
		"sScrollX": '100%',
		"sScrollXInner": 2100,
		"sAjaxSource":parent.basePath+"sys/LoanRepaymentLog/list",
		"fnServerData":retrieveData,  //自定义数据获取函数
		"aoColumns" : [ {
			"mDataProp" : "repayDate",
			"sTitle" : "收款时间",
			"bSortable": true,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				if(_is_empty(data)){
					return '';
				}
				return new Date(data).format('yyyy-MM-dd');
			}
		}, {
			"mDataProp" : "repayUserName",
			"sTitle" : "收款人",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				return data;
			}
		},{
			"mDataProp" : "repayAmount",
			"sTitle" : "收款金额",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				return data+'(元)';
			}
		},{
			"mDataProp" : "payType",
			"sTitle" : "交易方式",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				return top.SYS_BASE_DATA['Loan_Transaction_Mode_Code'][data];
			}
		}, {
			"mDataProp" : "payClientName",
			"sTitle" : "汇款人",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center"
		}, {
			"mDataProp" : "payBankName",
			"sTitle" : "汇款银行",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				return top.SYS_BASE_DATA['Client_Bank_Name_Code'][data];
			}
		}, {
			"mDataProp" : "payBankAccount",
			"sTitle" : "汇款银行账户",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center"
		}, {
			"mDataProp" : "repayRemark",
			"sTitle" : "收款备注",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
             if(_is_empty(data)){
            	 return '';
             }
             return data.length>20?(data.substring(0,20)+'......'):data;
			}
		}
		],
		"oLanguage": {
			"sUrl":parent.basePath+"static_resources/language/lang-cn.txt" //这个是国际化，也就是汉化的各种文字数据源，写对url就行了
		}
	});
	
	var url = 'sys/LoanExt/findRepaymentDetail?queryProxy[id]='+_param_id;
	_set_lable_text ('#loanRepaymentdetail ul.forminfo li span ','name',url,false);
	
	url = 'sys/LoanExt/findRepayment?queryProxy[id]='+repaymentId;
	_set_lable_text ('#loanRepayment ul.forminfo li span ','name',url,false);

});

//自定义数据获取函数
function retrieveData( sSource, aoData, fnCallback ) {
	aoData.push({name:'beanProxy[enable]',value:0});
	aoData.push({name:'beanProxy[loanId]',value:loanId});
	aoData.push({name:'beanProxy[repaymentDetailId]',value:_param_id});
	$.ajax( {
		type: "POST", 
		url: sSource, 
		cache : false,
		dataType : "json",
		data : aoData, 
		success: function(resp) {
			if(resp && resp.state == 200){
				fnCallback(resp.datagrid);
				return false;
			}
			fnCallback(null);
		}
	});
}
